﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Threading;
using Studio77.GuessTheWordsForWP7.Core;

namespace Studio77.GuessTheWordsForWP7
{
    public partial class LoadingPage : PhoneApplicationPage
    {
        public LoadingPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(LoadingPage_Loaded);
        }

        void LoadingPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= new RoutedEventHandler(LoadingPage_Loaded);
            this.logoStoryboard.Begin();
            Thread resourceLoadThread = new Thread(new ThreadStart(init));
            resourceLoadThread.Start();
        }


        private void init()
        {
            StageManager.Instance.InitAllStages();
            StageManager.Instance.LaunchCount = StageManager.Instance.LaunchCount + 1;
            Thread.Sleep(500);
            Dispatcher.BeginInvoke(()=>{
                NavigationService.Navigate(new Uri("/MainPage.xaml?fromloading=1", UriKind.Relative));
            });
        }


    }
}